﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Smart.Service.ServiceReference
{

    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    [System.ServiceModel.ServiceContractAttribute(ConfigurationName = "Service.IHttpService")]
    public interface IHttpService
    {

        [System.ServiceModel.OperationContractAttribute(AsyncPattern = true, Action = "http://tempuri.org/IHttpService/Execute", ReplyAction = "http://tempuri.org/IHttpService/ExecuteResponse")]
        System.IAsyncResult BeginExecute(string action, string request, System.AsyncCallback callback, object asyncState);

        string EndExecute(System.IAsyncResult result);

        [System.ServiceModel.OperationContractAttribute(AsyncPattern = true, Action = "http://tempuri.org/IHttpService/ExecuteMethod", ReplyAction = "http://tempuri.org/IHttpService/ExecuteMethodResponse")]
        System.IAsyncResult BeginExecuteMethod(string action, string parser, string method, string request, System.AsyncCallback callback, object asyncState);

        string EndExecuteMethod(System.IAsyncResult result);
    }

    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    public interface IHttpServiceChannel : Smart.Service.ServiceReference.IHttpService, System.ServiceModel.IClientChannel
    {
    }

    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    public partial class ExecuteCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs
    {

        private object[] results;

        public ExecuteCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
            base(exception, cancelled, userState)
        {
            this.results = results;
        }

        public string Result
        {
            get
            {
                base.RaiseExceptionIfNecessary();
                return ((string)(this.results[0]));
            }
        }
    }

    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    public partial class ExecuteMethodCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs
    {

        private object[] results;

        public ExecuteMethodCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
            base(exception, cancelled, userState)
        {
            this.results = results;
        }

        public string Result
        {
            get
            {
                base.RaiseExceptionIfNecessary();
                return ((string)(this.results[0]));
            }
        }
    }

    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    public partial class HttpServiceClient : System.ServiceModel.ClientBase<Smart.Service.ServiceReference.IHttpService>, Smart.Service.ServiceReference.IHttpService
    {

        private BeginOperationDelegate onBeginExecuteDelegate;

        private EndOperationDelegate onEndExecuteDelegate;

        private System.Threading.SendOrPostCallback onExecuteCompletedDelegate;

        private BeginOperationDelegate onBeginExecuteMethodDelegate;

        private EndOperationDelegate onEndExecuteMethodDelegate;

        private System.Threading.SendOrPostCallback onExecuteMethodCompletedDelegate;

        private BeginOperationDelegate onBeginOpenDelegate;

        private EndOperationDelegate onEndOpenDelegate;

        private System.Threading.SendOrPostCallback onOpenCompletedDelegate;

        private BeginOperationDelegate onBeginCloseDelegate;

        private EndOperationDelegate onEndCloseDelegate;

        private System.Threading.SendOrPostCallback onCloseCompletedDelegate;

        public HttpServiceClient()
        {
        }

        public HttpServiceClient(string endpointConfigurationName) :
            base(endpointConfigurationName)
        {
        }

        public HttpServiceClient(string endpointConfigurationName, string remoteAddress) :
            base(endpointConfigurationName, remoteAddress)
        {
        }

        public HttpServiceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) :
            base(endpointConfigurationName, remoteAddress)
        {
        }

        public HttpServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
            base(binding, remoteAddress)
        {
        }

        public System.Net.CookieContainer CookieContainer
        {
            get
            {
                System.ServiceModel.Channels.IHttpCookieContainerManager httpCookieContainerManager = this.InnerChannel.GetProperty<System.ServiceModel.Channels.IHttpCookieContainerManager>();
                if ((httpCookieContainerManager != null))
                {
                    return httpCookieContainerManager.CookieContainer;
                }
                else
                {
                    return null;
                }
            }
            set
            {
                System.ServiceModel.Channels.IHttpCookieContainerManager httpCookieContainerManager = this.InnerChannel.GetProperty<System.ServiceModel.Channels.IHttpCookieContainerManager>();
                if ((httpCookieContainerManager != null))
                {
                    httpCookieContainerManager.CookieContainer = value;
                }
                else
                {
                    throw new System.InvalidOperationException("无法设置 CookieContainer。请确保绑定包含 HttpCookieContainerBindingElement。");
                }
            }
        }

        public event System.EventHandler<ExecuteCompletedEventArgs> ExecuteCompleted;

        public event System.EventHandler<ExecuteMethodCompletedEventArgs> ExecuteMethodCompleted;

        public event System.EventHandler<System.ComponentModel.AsyncCompletedEventArgs> OpenCompleted;

        public event System.EventHandler<System.ComponentModel.AsyncCompletedEventArgs> CloseCompleted;

        [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
        System.IAsyncResult Smart.Service.ServiceReference.IHttpService.BeginExecute(string action, string request, System.AsyncCallback callback, object asyncState)
        {
            return base.Channel.BeginExecute(action, request, callback, asyncState);
        }

        [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
        string Smart.Service.ServiceReference.IHttpService.EndExecute(System.IAsyncResult result)
        {
            return base.Channel.EndExecute(result);
        }

        private System.IAsyncResult OnBeginExecute(object[] inValues, System.AsyncCallback callback, object asyncState)
        {
            string action = ((string)(inValues[0]));
            string request = ((string)(inValues[1]));
            return ((Smart.Service.ServiceReference.IHttpService)(this)).BeginExecute(action, request, callback, asyncState);
        }

        private object[] OnEndExecute(System.IAsyncResult result)
        {
            string retVal = ((Smart.Service.ServiceReference.IHttpService)(this)).EndExecute(result);
            return new object[] {
                    retVal};
        }

        private void OnExecuteCompleted(object state)
        {
            if ((this.ExecuteCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                this.ExecuteCompleted(this, new ExecuteCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }

        public void ExecuteAsync(string action, string request)
        {
            this.ExecuteAsync(action, request, null);
        }

        public void ExecuteAsync(string action, string request, object userState)
        {
            if ((this.onBeginExecuteDelegate == null))
            {
                this.onBeginExecuteDelegate = new BeginOperationDelegate(this.OnBeginExecute);
            }
            if ((this.onEndExecuteDelegate == null))
            {
                this.onEndExecuteDelegate = new EndOperationDelegate(this.OnEndExecute);
            }
            if ((this.onExecuteCompletedDelegate == null))
            {
                this.onExecuteCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnExecuteCompleted);
            }
            base.InvokeAsync(this.onBeginExecuteDelegate, new object[] {
                        action,
                        request}, this.onEndExecuteDelegate, this.onExecuteCompletedDelegate, userState);
        }

        [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
        System.IAsyncResult Smart.Service.ServiceReference.IHttpService.BeginExecuteMethod(string action, string parser, string method, string request, System.AsyncCallback callback, object asyncState)
        {
            return base.Channel.BeginExecuteMethod(action, parser, method, request, callback, asyncState);
        }

        [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
        string Smart.Service.ServiceReference.IHttpService.EndExecuteMethod(System.IAsyncResult result)
        {
            return base.Channel.EndExecuteMethod(result);
        }

        private System.IAsyncResult OnBeginExecuteMethod(object[] inValues, System.AsyncCallback callback, object asyncState)
        {
            string action = ((string)(inValues[0]));
            string parser = ((string)(inValues[1]));
            string method = ((string)(inValues[2]));
            string request = ((string)(inValues[3]));
            return ((Smart.Service.ServiceReference.IHttpService)(this)).BeginExecuteMethod(action, parser, method, request, callback, asyncState);
        }

        private object[] OnEndExecuteMethod(System.IAsyncResult result)
        {
            string retVal = ((Smart.Service.ServiceReference.IHttpService)(this)).EndExecuteMethod(result);
            return new object[] {
                    retVal};
        }

        private void OnExecuteMethodCompleted(object state)
        {
            if ((this.ExecuteMethodCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                this.ExecuteMethodCompleted(this, new ExecuteMethodCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }

        public void ExecuteMethodAsync(string action, string parser, string method, string request)
        {
            this.ExecuteMethodAsync(action, parser, method, request, null);
        }

        public void ExecuteMethodAsync(string action, string parser, string method, string request, object userState)
        {
            if ((this.onBeginExecuteMethodDelegate == null))
            {
                this.onBeginExecuteMethodDelegate = new BeginOperationDelegate(this.OnBeginExecuteMethod);
            }
            if ((this.onEndExecuteMethodDelegate == null))
            {
                this.onEndExecuteMethodDelegate = new EndOperationDelegate(this.OnEndExecuteMethod);
            }
            if ((this.onExecuteMethodCompletedDelegate == null))
            {
                this.onExecuteMethodCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnExecuteMethodCompleted);
            }
            base.InvokeAsync(this.onBeginExecuteMethodDelegate, new object[] {
                        action,
                        parser,
                        method,
                        request}, this.onEndExecuteMethodDelegate, this.onExecuteMethodCompletedDelegate, userState);
        }

        private System.IAsyncResult OnBeginOpen(object[] inValues, System.AsyncCallback callback, object asyncState)
        {
            return ((System.ServiceModel.ICommunicationObject)(this)).BeginOpen(callback, asyncState);
        }

        private object[] OnEndOpen(System.IAsyncResult result)
        {
            ((System.ServiceModel.ICommunicationObject)(this)).EndOpen(result);
            return null;
        }

        private void OnOpenCompleted(object state)
        {
            if ((this.OpenCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                this.OpenCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(e.Error, e.Cancelled, e.UserState));
            }
        }

        public void OpenAsync()
        {
            this.OpenAsync(null);
        }

        public void OpenAsync(object userState)
        {
            if ((this.onBeginOpenDelegate == null))
            {
                this.onBeginOpenDelegate = new BeginOperationDelegate(this.OnBeginOpen);
            }
            if ((this.onEndOpenDelegate == null))
            {
                this.onEndOpenDelegate = new EndOperationDelegate(this.OnEndOpen);
            }
            if ((this.onOpenCompletedDelegate == null))
            {
                this.onOpenCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnOpenCompleted);
            }
            base.InvokeAsync(this.onBeginOpenDelegate, null, this.onEndOpenDelegate, this.onOpenCompletedDelegate, userState);
        }

        private System.IAsyncResult OnBeginClose(object[] inValues, System.AsyncCallback callback, object asyncState)
        {
            return ((System.ServiceModel.ICommunicationObject)(this)).BeginClose(callback, asyncState);
        }

        private object[] OnEndClose(System.IAsyncResult result)
        {
            ((System.ServiceModel.ICommunicationObject)(this)).EndClose(result);
            return null;
        }

        private void OnCloseCompleted(object state)
        {
            if ((this.CloseCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                this.CloseCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(e.Error, e.Cancelled, e.UserState));
            }
        }

        public void CloseAsync()
        {
            this.CloseAsync(null);
        }

        public void CloseAsync(object userState)
        {
            if ((this.onBeginCloseDelegate == null))
            {
                this.onBeginCloseDelegate = new BeginOperationDelegate(this.OnBeginClose);
            }
            if ((this.onEndCloseDelegate == null))
            {
                this.onEndCloseDelegate = new EndOperationDelegate(this.OnEndClose);
            }
            if ((this.onCloseCompletedDelegate == null))
            {
                this.onCloseCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnCloseCompleted);
            }
            base.InvokeAsync(this.onBeginCloseDelegate, null, this.onEndCloseDelegate, this.onCloseCompletedDelegate, userState);
        }

        protected override Smart.Service.ServiceReference.IHttpService CreateChannel()
        {
            return new HttpServiceClientChannel(this);
        }

        private class HttpServiceClientChannel : ChannelBase<Smart.Service.ServiceReference.IHttpService>, Smart.Service.ServiceReference.IHttpService
        {

            public HttpServiceClientChannel(System.ServiceModel.ClientBase<Smart.Service.ServiceReference.IHttpService> client) :
                base(client)
            {
            }

            public System.IAsyncResult BeginExecute(string action, string request, System.AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[2];
                _args[0] = action;
                _args[1] = request;
                System.IAsyncResult _result = base.BeginInvoke("Execute", _args, callback, asyncState);
                return _result;
            }

            public string EndExecute(System.IAsyncResult result)
            {
                object[] _args = new object[0];
                string _result = ((string)(base.EndInvoke("Execute", _args, result)));
                return _result;
            }

            public System.IAsyncResult BeginExecuteMethod(string action, string parser, string method, string request, System.AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[4];
                _args[0] = action;
                _args[1] = parser;
                _args[2] = method;
                _args[3] = request;
                System.IAsyncResult _result = base.BeginInvoke("ExecuteMethod", _args, callback, asyncState);
                return _result;
            }

            public string EndExecuteMethod(System.IAsyncResult result)
            {
                object[] _args = new object[0];
                string _result = ((string)(base.EndInvoke("ExecuteMethod", _args, result)));
                return _result;
            }
        }
    }

}
